package org.jeecg.modules.jxc.basicdata.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.jxc.basicdata.entity.GoodsType;
import org.jeecg.modules.jxc.basicdata.mapper.GoodsTypeMapper;
import org.jeecg.modules.jxc.basicdata.service.IGoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yaorange
 * @since 2021-10-27
 */
@RestController
@RequestMapping("/goods-type")
public class GoodsTypeController {
    @Autowired
    private IGoodsTypeService goodsTypeService;
    @Resource
    private GoodsTypeMapper goodsTypeMapper;

    /**
     * 根据传来的id查询他的子节点
     * @param id
     * @return
     */
    @GetMapping("/getByParentId/{id}")
    public ResponseEntity<?> getByParentId(@PathVariable Integer id){
        QueryWrapper<GoodsType> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("*");
        queryWrapper.eq("p_id", id);
        List<GoodsType> list = goodsTypeMapper.selectList(queryWrapper);
        return ResponseEntity.ok(list);
    }



}

